﻿using ViewMaker.Core.Controls;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using ViewMaker.Core;
using System.Collections.Generic;
using System.Xml;
using System.Windows.Markup;
using System.Windows.Controls;
using System.Windows.Data;

namespace ViewMaker.Core.Tests
{

    [TestClass()]
    public class CheckBoxViewControlTest
    {

        [TestMethod()]
        public void 標準的なCheckBoxのXAML生成()
        {
            var target = new CheckBoxViewControl { Item = new ViewLayoutItem { Name="cb001", Caption = "チェックボックス", BindPath="CheckPath" } };
            var xaml = target.CreateXaml(TestHelper.CreateTestParent())[1];

            var actual = TestHelper.GetFrameworkElement<CheckBox>(xaml);
            Assert.AreEqual("cb001", actual.Name);
            Assert.AreEqual("CheckPath", actual.GetBindingExpression(CheckBox.IsCheckedProperty).ParentBinding.Path.Path);
            Assert.AreEqual(BindingMode.TwoWay, actual.GetBindingExpression(CheckBox.IsCheckedProperty).ParentBinding.Mode);

        }

        [TestMethod()]
        public void 読み取り専用のCheckBoxのXAML生成()
        {
            var target = new CheckBoxViewControl { Item = new ViewLayoutItem { Name = "cb001", Caption = "チェックボックス", BindPath = "CheckPath", IsOneWay=true } };
            var xaml = target.CreateXaml(TestHelper.CreateTestParent())[1];

            var actual = TestHelper.GetFrameworkElement<CheckBox>(xaml);
            Assert.AreEqual("cb001", actual.Name);
            Assert.AreEqual("CheckPath", actual.GetBindingExpression(CheckBox.IsCheckedProperty).ParentBinding.Path.Path);
            Assert.AreEqual(BindingMode.OneWay, actual.GetBindingExpression(CheckBox.IsCheckedProperty).ParentBinding.Mode);

        }

        [TestMethod()]
        public void CheckBoxViewControlの編集画面が表示可能()
        {
            var target = new CheckBoxViewControl { Item = new ViewLayoutItem { Name = "cb001", Caption = "チェックボックス", BindPath = "CheckPath" } };
            var baml = ViewUtil.BuildContent(target);
            Assert.IsNotNull(baml);
        }

    }
}
